package org.example.com.zwh.service;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

@Component
public class ConsumerHealthIndicator implements HealthIndicator {
    private volatile boolean consumerRunning = true;

    public void setConsumerRunning(boolean running) {
        this.consumerRunning = running;
    }

    @Override
    public Health health() {
        return consumerRunning ?
                Health.up().withDetail("message", "消费线程运行正常").build() :
                Health.down().withDetail("error", "消费线程已停止").build();
    }

}
